<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,height=device-height">
    <link rel="stylesheet" href="<?php echo base_url().'public/home/' ?>css/general.css">
    <link rel="stylesheet" href="<?php echo base_url().'public/home/' ?>css/feedback.css">
    <script src="<?php echo base_url().'public/home/' ?>js/jquery-2.0.3.min.js"></script>
    <!-- 日期选择控件 -->
    <script src='<?php echo base_url().'public/home/mobile_date/' ?>jdate.min.js'></script>
    <!-- 下拉框 -->
    <?php include_once "public/home/html/mobile_select.php"  ?>
    <title>信息反馈统计报表</title>
</head>
<style>
    
.filter-item input{
    width: 75%;
    float: left;
    border: none;
    margin-top: 4px;
    color: #797979;
    overflow:hidden;
      text-overflow: ellipsis;
      white-space:nowrap;
      text-align: center;
      margin-right: 5px;
}
.filter-item img{
    width: 13px;
    float: left;
    margin: 8px 0 0 0;
}
.filter{
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 50px;
    background: #fff;
}
.filter div{
    float: left;
}
a{
    text-decoration:none;
    color:#3577F7;
}
</style>
<body>
    <input type="hidden" name="admin_id" id="admin_id"value="<?php echo $_SESSION[SESS_USER_HOME]['id'] ?>">
    <input type="hidden" name="url" id="url"value="<?php echo base_url() ?>">
    <div class='filter'>
            <div class="filter-item">
                <input type="text" id="date" onchange="getList(true)" value="" placeholder="选择日期"><img src="<?php echo base_url().'public/home/' ?>images/drop_down.png" alt="">
            </div>
            
            <!-- 管理员显示 -->
            <?php if($identity==1):?>
            <div class="filter-item">
                <input type="text" id="dept" onchange="getList(true)" placeholder="选择部门" readonly><img src="<?php echo base_url().'public/home/' ?>images/drop_down.png" alt="">
            </div>
            <?php endif?>
        </div>
    </div>
<div class="min">


</div>

<div class="botn">
        
</div>

<div class="loading" style="text-align:center;"><img src="<?php echo base_url().'public/home/' ?>images/loading1.gif"></div>

<div class="tip" style="display: none;text-align:center;color: #5d5d5d;height: 30px;">到底了,没有数据了~</div>


<script>
    
    let pageNo='1';
    let pageSize='20'
    let have=true;
    let total = 0;
    $(function () {

        console.log(pageNo);
        console.log(pageSize);
        new Jdate({
			  el: '#date',
			  format: 'YYYY-MM-DD',
			  beginYear: 2019,
			  endYear:  new Date().getFullYear(),              
				confirm: function(date) {
					$("#date").val(date)
                    have=true;
                    getList(true)
				},
			})

        getList();
        getOption()
        //分页
        $(window).scroll(function(){
            // scroll at bottom
            if ($(window).scrollTop() + $(window).height() == $(document).height()) {
                pageNo++;
                getList()
            }
        });
    })
    function getList(change=false){
        if(have){
            if(change){
                pageNo=1
                have=true
                $(".min").html('')
            }
            var date=$("#date").val() 
            if($("#date").val()=='请选择日期'){
                date='';
            }   
            $.ajax({
                url: $("#url").val()+"/Home/Attend/informationFeedback",
                dataType:"json",
                type: "post",
                data: {
                    pageNo:pageNo,
                    pageSize:pageSize,
                    dept_name:$("#dept").val(),
                    created:date,
                },
                success: function (data) {
                    let t = JSON.parse(data.v);
                    console.log(t);
                    let html = '';
                    total += t.all_count;


                    // 总计反馈 数据累加
                     html +=`<div class="bot">
                             <span>总计反馈：</span><span>${total}</span></div>
                             `
                             $('.botn').append(html);
                    
                    $.each(t.ret, function (k, v) {
                        let a = (pageNo-1)*pageSize+(k+1) + '.' ;

                        html+=`<div class="fk" onclick="gotoDetail(${v.creator})">
                        <div class="name" style="margin:0 5px;font-size:18px;">
                        <div style="float: left;">${a}${v.username}(${v.dept_name})</div>
                            <div class="spd" style="color:blue;cursor:pointer;text-align:right;font-size: 18px;">累计${v.count}次反馈</span></div>
                            </div>
                        </div>`      
                    });
                    
                    // 判断是否还有数据
                    if( pageNo==t.totalPage || t.totalPage==0){
                        have=false
                        $(".loading").hide();
                        $(".tip").show();
                    }
                    $('.min').append(html);

                },
            });
        }
    }

    function gotoDetail(creator){
        window.location.href="./feedback_ist?creator="+creator
    }
    
    // 获取筛选项
    function getOption(){
        $.ajax({
            type: "post",
            url: $("#url").val()+"Home/Attend/feedbackScreen",
            dataType: "json",
            success: function (data) {
                var t=JSON.parse(data.v)
                console.log(t);

                new MobileSelect({
                    trigger: '#dept',
                    title: '请选择部门',
                    wheels: [
                                {data: t.dept_name}
                            ],
                    callback:function(indexArr, data){
                        $("#dept").val(data)
                        getList(true)
                    }
                });

            }
        });
    }

    </script>
</body>

</html>